package com.cloudsigns.factorymanager2.engineering.presenter;

import com.cloudsigns.factorymanager2.engineering.IView.IEditEngineeringInstallOrderView;
import com.cloudsigns.factorymanager2.engineering.IView.IEditPublicationOrderView;
import com.cloudsigns.factorymanager2.engineering.model.EditEngineeringInstallOrderModel;
import com.cloudsigns.factorymanager2.engineering.model.EditPublicationOrderModel;
import com.cloudsigns.factorymanager2.engineering.model.IEditEngineeringInstallOrderModel;
import com.cloudsigns.factorymanager2.engineering.model.IEditPublicationOrderModel;

/**
 * Created by tony on 2018/5/17.
 */

public class EditPublicationOrderPresenter {
    private IEditPublicationOrderView view;
    private IEditPublicationOrderModel model;
    private android.os.Handler mHandler = new android.os.Handler();

    public EditPublicationOrderPresenter(IEditPublicationOrderView view) {
        this.view = view;
        this.model = new EditPublicationOrderModel();
    }

    public void editPublicationOrder() {


        model.editPublicationOrder(view.getBeginDate(), view.getFinishDate(), view.getId(), new EditPublicationOrderModel.OnEditPublicationOrderListener() {
            @Override
            public void editPublicationOrderSunccessed() {
                //需要在UI线程执行
                mHandler.post(new Runnable() {
                    @Override
                    public void run() {
                        view.editPublicationOrderSunccessed();
                        view.hideLoading();
                    }
                });
            }

            @Override
            public void editPublicationOrderFailed(final String desc) {
                //需要在UI线程执行
                mHandler.post(new Runnable() {
                    @Override
                    public void run() {
                        view.editPublicationOrderFailed(desc);
                        view.hideLoading();
                    }
                });
            }
        });

    }
}
